package com.itbaizhan;
//StringBuilder与StringBuffer
public class TestString03 {
    public static void main(String[] args) {
        /*StringBuilder*/
        StringBuilder s = new StringBuilder();
        for(int i= 0;i<7;i++){
            s.append((char)('a'+i));
        }
        System.out.println(s.toString());
        //s.append("1").append("2").append("w");
        s.append(",I can sing my abc!");
        System.out.println(s.toString());
        /*StringBuffer,下面的方法同样适用StringBuilder*/
        StringBuffer s2 = new StringBuffer("北京尚学堂");
        s2.insert(0,"爱").insert(0,"我");
        System.out.println(s2);
        s2.delete(0,2);
        System.out.println(s2);
        s2.deleteCharAt(0).deleteCharAt(0);//删除某个字符
        System.out.println(s2.charAt(0));//提取某个字符
        System.out.println(s2.reverse());//字符逆转

    }
}
